<?php
$code = $_POST["code"];
$appid = "wxa825ebeca9e83efc";
$secret = "3509ce78b2f8f329431b29be500cdaa0";

//获取openid
$res = file_get_contents("https://api.weixin.qq.com/sns/jscode2session?appid=".$appid."&secret=".$secret."&js_code=".$code."&grant_type=authorization_code");

//去掉session_key并返回数据
$res_arr = json_decode($res, true);
unset($res_arr["session_key"]);
echo json_encode($res_arr);